package c.c.b.a.b.a.i;

import c.b.a.a.a;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/* compiled from: OptionalMethod */
public class d<T> {
    public final Class<?> a;
    public final String b;
    public final Class[] c;

    public d(Class<?> cls, String str, Class... clsArr) {
        this.a = cls;
        this.b = str;
        this.c = clsArr;
    }

    /* JADX WARNING: Removed duplicated region for block: B:13:0x0016  */
    /* JADX WARNING: Missing block: B:8:0x0011, code skipped:
            if ((r4.getModifiers() & 1) == 0) goto L_0x0013;
     */
    public final java.lang.reflect.Method a(java.lang.Class<?> r4) {
        /*
        r3 = this;
        r0 = r3.b;
        r1 = 0;
        if (r0 == 0) goto L_0x0026;
    L_0x0005:
        r2 = r3.c;
        r4 = r4.getMethod(r0, r2);	 Catch:{ NoSuchMethodException -> 0x0013 }
        r0 = r4.getModifiers();	 Catch:{ NoSuchMethodException -> 0x0014 }
        r0 = r0 & 1;
        if (r0 != 0) goto L_0x0014;
    L_0x0013:
        r4 = r1;
    L_0x0014:
        if (r4 == 0) goto L_0x0025;
    L_0x0016:
        r0 = r3.a;
        if (r0 == 0) goto L_0x0025;
    L_0x001a:
        r2 = r4.getReturnType();
        r0 = r0.isAssignableFrom(r2);
        if (r0 != 0) goto L_0x0025;
    L_0x0024:
        goto L_0x0026;
    L_0x0025:
        r1 = r4;
    L_0x0026:
        return r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.c.b.a.b.a.i.d.a(java.lang.Class):java.lang.reflect.Method");
    }

    public Object b(T t, Object... objArr) {
        try {
            Method a = a(t.getClass());
            Object obj = null;
            if (a == null) {
                return null;
            }
            try {
                obj = a.invoke(t, objArr);
                return obj;
            } catch (IllegalAccessException unused) {
                return obj;
            }
        } catch (InvocationTargetException e) {
            Throwable targetException = e.getTargetException();
            if (targetException instanceof RuntimeException) {
                throw ((RuntimeException) targetException);
            }
            AssertionError assertionError = new AssertionError("Unexpected exception");
            assertionError.initCause(targetException);
            throw assertionError;
        }
    }

    public Object c(T t, Object... objArr) throws InvocationTargetException {
        Method a = a(t.getClass());
        if (a != null) {
            try {
                return a.invoke(t, objArr);
            } catch (IllegalAccessException e) {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("Unexpectedly could not call: ");
                stringBuilder.append(a);
                AssertionError assertionError = new AssertionError(stringBuilder.toString());
                assertionError.initCause(e);
                throw assertionError;
            }
        }
        StringBuilder g = a.g("Method ");
        g.append(this.b);
        g.append(" not supported for object ");
        g.append(t);
        throw new AssertionError(g.toString());
    }

    public Object d(T t, Object... objArr) {
        try {
            return c(t, objArr);
        } catch (InvocationTargetException e) {
            Throwable targetException = e.getTargetException();
            if (targetException instanceof RuntimeException) {
                throw ((RuntimeException) targetException);
            }
            AssertionError assertionError = new AssertionError("Unexpected exception");
            assertionError.initCause(targetException);
            throw assertionError;
        }
    }
}
